# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=xkbsel
pkgver=0.13
pkgrel=11
pkgdesc="framework for defining, selecting and indicating XKB keyboard mappings"
arch=('loong64' 'x86_64')
url="https://www.meduna.org/sw_xkbsel_en.html"
license=('GPL')
depends=('gdbm' 'libxaw')
makedepends=('patch' 'xkeyboard-config')
source=(https://www.meduna.org/code/$pkgname-$pkgver.tar.gz
	build-fix.patch)
sha512sums=('2cefeac975335ab07b6b375f7109d8ac8ba733e4024e6a64c8e8a8757cf194882ccd436937c648ce0f3a7a2112208600f1b5ad2d73c82988a7f8c357362ccfc5'
            '850e9ee70839597b9b7485cec1eecf2f6c05da0392238620ad05397695897faf8a4fec1925f402eb64d61ecbeb1b7d42149db9f8b9436af3eeb27c675a3287fe')

prepare() {
  cd "$srcdir"/$pkgname-$pkgver
  sed -i 's|\${CC-cc}|${CC-cc} -O2 |g' ./configure
  patch -Np1 <../build-fix.patch
}

build() {
  cd "$srcdir"/$pkgname-$pkgver
  export CFLAGS="$CFLAGS -I/usr/include/gdbm -DHAVE_NDBM_H -ffat-lto-objects"
  export LDFLAGS="-lgdbm -lgdbm_compat"
  ./configure --prefix=/usr --localstatedir=/var/lib --sysconfdir=/etc/xkbsel \
		--build=`uname -m` --host=`uname -m` --target=`uname -m` \
		--mandir=/usr/share/man
  make
}

package() {
  cd "$srcdir"/$pkgname-$pkgver
  make DESTDIR="$pkgdir" install
}
